const {con,ResData} = require('./common.js');

async function getArea(){
  const res = new ResData();
  const sql = 'select * from areas';
  const [rows] = await con.execute(sql);
  //console.log(rows);
  return res.data = rows;
}
async function addArea(areaName){
  const res = new ResData();
  const sql = `insert into areas(area_name) values("${areaName}")`;
const [rows] = await con.execute(sql);
res.msg = rows.affectedRows === 1 ?'添加成功':'添加失败';
console.log(rows);
  return res;
}
async function updateArea(){
  const res = new ResData();
  return res;
}
async function delArea(){
  const res = new ResData();
  return res;
}


module.exports={
  getArea,
  addArea,
  updateArea,
  delArea
}
